package com.td.module.system.controller.app.dict;

import com.td.framework.common.pojo.CommonResult;
import com.td.module.system.controller.admin.dict.vo.type.DictTypeSimpleRespVO;
import com.td.module.system.convert.dict.DictTypeConvert;
import com.td.module.system.dal.dataobject.dict.DictTypeDO;
import com.td.module.system.service.dict.DictTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static com.td.framework.common.pojo.CommonResult.success;

/**
 * #author:  WangXX
 * #FileName: AppDictTypeController
 * #create: 2022/9/19
 */
@Api(tags = "app - 字典类型")
@RestController
@RequestMapping("/appSystem/dict-type")
@Validated
public class AppDictTypeController {
    @Resource
    private DictTypeService dictTypeService;

    @GetMapping("/list-all-simple")
    @ApiOperation(value = "获得全部字典类型列表", notes = "包括开启 + 禁用的字典类型，主要用于前端的下拉选项")
    // 无需添加权限认证，因为前端全局都需要
    public CommonResult<List<DictTypeSimpleRespVO>> listSimpleDictTypes() {
        List<DictTypeDO> list = dictTypeService.getDictTypeList();
        return success(DictTypeConvert.INSTANCE.convertList(list));
    }
}
